<?php
/* @var $this PostController */
/* @var $model Post */
/* @var $form CActiveForm */
?>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/views/form-product.css" />
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'post-form',
	'htmlOptions' => array(
        'enctype' => 'multipart/form-data',
    ),
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<!-- <div class="row">
		<?php echo $form->labelEx($model,'post_author'); ?>
		<?php echo $form->textField($model,'post_author',array('size'=>11,'maxlength'=>11)); ?>
		<?php echo $form->error($model,'post_author'); ?>
	</div> -->

	<div class="row">
		<?php echo $form->labelEx($model,'post_title'); ?>
		<?php echo $form->textField($model,'post_title',array('size'=>60,'maxlength'=>200)); ?>
		<?php echo $form->error($model,'post_title'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'image_link'); ?>
		<?php echo CHtml::activeFileField($model,'image_link',array('id'=>'imgInp')); ?>
		<?php echo $form->error($model,'image_link'); ?>
	</div>
	<?php
		if (!empty($model->image_link)) {
			echo CHtml::image(Yii::app()->request->baseUrl.'/images/posts/'.$model->image_link,$model->post_title , array('id'=>'preview'));
		} else {
			echo "<img id='preview' src='http://placehold.it/140x100' alt='preview de la imagen 123' />";
		}
	?>

	<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl;?>/js/ckeditor/ckeditor.js"></script>
	<div class="row">
		<?php echo $form->labelEx($model,'post_content'); ?>
		<?php echo $form->textArea($model,'post_content',array('rows'=>10, 'id'=>'text_post_content')); ?>
		<?php echo $form->error($model,'post_content'); ?>
	</div>
	<script type="text/javascript">
		CKEDITOR.replace('text_post_content',
			{
				filebrowserBrowseUrl :  '/thanhshop/js/ckeditor/ckfinder/ckfinder.html' , 
			    filebrowserImageBrowseUrl :  '/thanhshop/js/ckeditor/ckfinder/ckfinder.html?Type=Images' , 
			    filebrowserFlashBrowseUrl :  '/thanhshop/js/ckeditor/ckfinder/ckfinder.html?Type=Flash' , 
			    filebrowserUploadUrl :  '/thanhshop/js/ckeditor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files' , 
			    filebrowserImageUploadUrl :  '/thanhshop/js/ckeditor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images' , 
			    filebrowserFlashUploadUrl :  '/thanhshop/js/ckeditor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash' 

			});
	</script>

	<div class="row">
		<?php echo $form->labelEx($model,'group_id'); ?>
		<?php echo $form->dropDownList($model,'group_id', $litsGroupPost); ?>
		<?php echo $form->error($model,'group_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'featured'); ?>
		<?php echo $form->checkBox($model,'featured'); ?>
		<?php echo $form->error($model,'featured'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl;?>/js/upload-image.js"></script>